<?php
	/**
	 * This is a MetaControl class, providing a QForm or QPanel access to event handlers
	 * and QControls to perform the Create, Edit, and Delete functionality
	 * of the MantisConfigTable class.  This code-generated class
	 * contains all the basic elements to help a QPanel or QForm display an HTML form that can
	 * manipulate a single MantisConfigTable object.
	 *
	 * To take advantage of some (or all) of these control objects, you
	 * must create a new QForm or QPanel which instantiates a MantisConfigTableMetaControl
	 * class.
	 *
	 * Any and all changes to this file will be overwritten with any subsequent
	 * code re-generation.
	 *
	 * @package My QCubed Application
	 * @subpackage MetaControls
	 * @property-read MantisConfigTable $MantisConfigTable the actual MantisConfigTable data class being edited
	 * @property QTextBox $ConfigIdControl
	 * @property-read QLabel $ConfigIdLabel
	 * @property QIntegerTextBox $ProjectIdControl
	 * @property-read QLabel $ProjectIdLabel
	 * @property QIntegerTextBox $UserIdControl
	 * @property-read QLabel $UserIdLabel
	 * @property QIntegerTextBox $AccessReqdControl
	 * @property-read QLabel $AccessReqdLabel
	 * @property QIntegerTextBox $TypeControl
	 * @property-read QLabel $TypeLabel
	 * @property QTextBox $ValueControl
	 * @property-read QLabel $ValueLabel
	 * @property-read string $TitleVerb a verb indicating whether or not this is being edited or created
	 * @property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
	 */

	class MantisConfigTableMetaControlGen extends QBaseClass {
		// General Variables
		/**
		 * @var MantisConfigTable objMantisConfigTable
		 * @access protected
		 */
		protected $objMantisConfigTable;
		/**
		 * @var QForm|QControl objParentObject
		 * @access protected
		 */
		protected $objParentObject;
		/**
		 * @var string strTitleVerb
		 * @access protected
		 */
		protected $strTitleVerb;
		/**
		 * @var boolean blnEditMode
		 * @access protected
		 */
		protected $blnEditMode;

		// Controls that allow the editing of MantisConfigTable's individual data fields
		/**
		 * @var QTextBox txtConfigId
		 * @access protected
		 */
		protected $txtConfigId;
		/**
		 * @var QIntegerTextBox txtProjectId
		 * @access protected
		 */
		protected $txtProjectId;
		/**
		 * @var QIntegerTextBox txtUserId
		 * @access protected
		 */
		protected $txtUserId;
		/**
		 * @var QIntegerTextBox txtAccessReqd
		 * @access protected
		 */
		protected $txtAccessReqd;
		/**
		 * @var QIntegerTextBox txtType
		 * @access protected
		 */
		protected $txtType;
		/**
		 * @var QTextBox txtValue
		 * @access protected
		 */
		protected $txtValue;

		// Controls that allow the viewing of MantisConfigTable's individual data fields
		/**
		 * @var QLabel lblConfigId
		 * @access protected
		 */
		protected $lblConfigId;
		/**
		 * @var QLabel lblProjectId
		 * @access protected
		 */
		protected $lblProjectId;
		/**
		 * @var QLabel lblUserId
		 * @access protected
		 */
		protected $lblUserId;
		/**
		 * @var QLabel lblAccessReqd
		 * @access protected
		 */
		protected $lblAccessReqd;
		/**
		 * @var QLabel lblType
		 * @access protected
		 */
		protected $lblType;
		/**
		 * @var QLabel lblValue
		 * @access protected
		 */
		protected $lblValue;

		// QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References

		// QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References


		/**
		 * Main constructor.  Constructor OR static create methods are designed to be called in either
		 * a parent QPanel or the main QForm when wanting to create a
		 * MantisConfigTableMetaControl to edit a single MantisConfigTable object within the
		 * QPanel or QForm.
		 *
		 * This constructor takes in a single MantisConfigTable object, while any of the static
		 * create methods below can be used to construct based off of individual PK ID(s).
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisConfigTableMetaControl
		 * @param MantisConfigTable $objMantisConfigTable new or existing MantisConfigTable object
		 */
		 public function __construct($objParentObject, MantisConfigTable $objMantisConfigTable) {
			// Setup Parent Object (e.g. QForm or QPanel which will be using this MantisConfigTableMetaControl)
			$this->objParentObject = $objParentObject;

			// Setup linked MantisConfigTable object
			$this->objMantisConfigTable = $objMantisConfigTable;

			// Figure out if we're Editing or Creating New
			if ($this->objMantisConfigTable->__Restored) {
				$this->strTitleVerb = QApplication::Translate('Edit');
				$this->blnEditMode = true;
			} else {
				$this->strTitleVerb = QApplication::Translate('Create');
				$this->blnEditMode = false;
			}
		 }

		/**
		 * Static Helper Method to Create using PK arguments
		 * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
		 * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
		 * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to
		 * edit, or if we are also allowed to create a new one, etc.
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisConfigTableMetaControl
		 * @param string $strConfigId primary key value
		 * @param integer $intProjectId primary key value
		 * @param integer $intUserId primary key value
		 * @param QMetaControlCreateType $intCreateType rules governing MantisConfigTable object creation - defaults to CreateOrEdit
 		 * @return MantisConfigTableMetaControl
		 */
		public static function Create($objParentObject, $strConfigId = null, $intProjectId = null, $intUserId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			// Attempt to Load from PK Arguments
			if (strlen($strConfigId) && strlen($intProjectId) && strlen($intUserId)) {
				$objMantisConfigTable = MantisConfigTable::Load($strConfigId, $intProjectId, $intUserId);

				// MantisConfigTable was found -- return it!
				if ($objMantisConfigTable)
					return new MantisConfigTableMetaControl($objParentObject, $objMantisConfigTable);

				// If CreateOnRecordNotFound not specified, throw an exception
				else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
					throw new QCallerException('Could not find a MantisConfigTable object with PK arguments: ' . $strConfigId . ', ' . $intProjectId . ', ' . $intUserId);

			// If EditOnly is specified, throw an exception
			} else if ($intCreateType == QMetaControlCreateType::EditOnly)
				throw new QCallerException('No PK arguments specified');

			// If we are here, then we need to create a new record
			return new MantisConfigTableMetaControl($objParentObject, new MantisConfigTable());
		}

		/**
		 * Static Helper Method to Create using PathInfo arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisConfigTableMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing MantisConfigTable object creation - defaults to CreateOrEdit
		 * @return MantisConfigTableMetaControl
		 */
		public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$strConfigId = QApplication::PathInfo(0);
			$intProjectId = QApplication::PathInfo(1);
			$intUserId = QApplication::PathInfo(2);
			return MantisConfigTableMetaControl::Create($objParentObject, $strConfigId, $intProjectId, $intUserId, $intCreateType);
		}

		/**
		 * Static Helper Method to Create using QueryString arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisConfigTableMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing MantisConfigTable object creation - defaults to CreateOrEdit
		 * @return MantisConfigTableMetaControl
		 */
		public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$strConfigId = QApplication::QueryString('strConfigId');
			$intProjectId = QApplication::QueryString('intProjectId');
			$intUserId = QApplication::QueryString('intUserId');
			return MantisConfigTableMetaControl::Create($objParentObject, $strConfigId, $intProjectId, $intUserId, $intCreateType);
		}



		///////////////////////////////////////////////
		// PUBLIC CREATE and REFRESH METHODS
		///////////////////////////////////////////////

		/**
		 * Create and setup QTextBox txtConfigId
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtConfigId_Create($strControlId = null) {
			$this->txtConfigId = new QTextBox($this->objParentObject, $strControlId);
			$this->txtConfigId->Name = QApplication::Translate('Config Id');
			$this->txtConfigId->Text = $this->objMantisConfigTable->ConfigId;
			$this->txtConfigId->Required = true;
			$this->txtConfigId->MaxLength = MantisConfigTable::ConfigIdMaxLength;
			return $this->txtConfigId;
		}

		/**
		 * Create and setup QLabel lblConfigId
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblConfigId_Create($strControlId = null) {
			$this->lblConfigId = new QLabel($this->objParentObject, $strControlId);
			$this->lblConfigId->Name = QApplication::Translate('Config Id');
			$this->lblConfigId->Text = $this->objMantisConfigTable->ConfigId;
			$this->lblConfigId->Required = true;
			return $this->lblConfigId;
		}

		/**
		 * Create and setup QIntegerTextBox txtProjectId
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtProjectId_Create($strControlId = null) {
			$this->txtProjectId = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtProjectId->Name = QApplication::Translate('Project Id');
			$this->txtProjectId->Text = $this->objMantisConfigTable->ProjectId;
			$this->txtProjectId->Required = true;
			return $this->txtProjectId;
		}

		/**
		 * Create and setup QLabel lblProjectId
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblProjectId_Create($strControlId = null, $strFormat = null) {
			$this->lblProjectId = new QLabel($this->objParentObject, $strControlId);
			$this->lblProjectId->Name = QApplication::Translate('Project Id');
			$this->lblProjectId->Text = $this->objMantisConfigTable->ProjectId;
			$this->lblProjectId->Required = true;
			$this->lblProjectId->Format = $strFormat;
			return $this->lblProjectId;
		}

		/**
		 * Create and setup QIntegerTextBox txtUserId
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtUserId_Create($strControlId = null) {
			$this->txtUserId = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtUserId->Name = QApplication::Translate('User Id');
			$this->txtUserId->Text = $this->objMantisConfigTable->UserId;
			$this->txtUserId->Required = true;
			return $this->txtUserId;
		}

		/**
		 * Create and setup QLabel lblUserId
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblUserId_Create($strControlId = null, $strFormat = null) {
			$this->lblUserId = new QLabel($this->objParentObject, $strControlId);
			$this->lblUserId->Name = QApplication::Translate('User Id');
			$this->lblUserId->Text = $this->objMantisConfigTable->UserId;
			$this->lblUserId->Required = true;
			$this->lblUserId->Format = $strFormat;
			return $this->lblUserId;
		}

		/**
		 * Create and setup QIntegerTextBox txtAccessReqd
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtAccessReqd_Create($strControlId = null) {
			$this->txtAccessReqd = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtAccessReqd->Name = QApplication::Translate('Access Reqd');
			$this->txtAccessReqd->Text = $this->objMantisConfigTable->AccessReqd;
			return $this->txtAccessReqd;
		}

		/**
		 * Create and setup QLabel lblAccessReqd
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblAccessReqd_Create($strControlId = null, $strFormat = null) {
			$this->lblAccessReqd = new QLabel($this->objParentObject, $strControlId);
			$this->lblAccessReqd->Name = QApplication::Translate('Access Reqd');
			$this->lblAccessReqd->Text = $this->objMantisConfigTable->AccessReqd;
			$this->lblAccessReqd->Format = $strFormat;
			return $this->lblAccessReqd;
		}

		/**
		 * Create and setup QIntegerTextBox txtType
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtType_Create($strControlId = null) {
			$this->txtType = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtType->Name = QApplication::Translate('Type');
			$this->txtType->Text = $this->objMantisConfigTable->Type;
			return $this->txtType;
		}

		/**
		 * Create and setup QLabel lblType
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblType_Create($strControlId = null, $strFormat = null) {
			$this->lblType = new QLabel($this->objParentObject, $strControlId);
			$this->lblType->Name = QApplication::Translate('Type');
			$this->lblType->Text = $this->objMantisConfigTable->Type;
			$this->lblType->Format = $strFormat;
			return $this->lblType;
		}

		/**
		 * Create and setup QTextBox txtValue
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtValue_Create($strControlId = null) {
			$this->txtValue = new QTextBox($this->objParentObject, $strControlId);
			$this->txtValue->Name = QApplication::Translate('Value');
			$this->txtValue->Text = $this->objMantisConfigTable->Value;
			$this->txtValue->Required = true;
			$this->txtValue->TextMode = QTextMode::MultiLine;
			return $this->txtValue;
		}

		/**
		 * Create and setup QLabel lblValue
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblValue_Create($strControlId = null) {
			$this->lblValue = new QLabel($this->objParentObject, $strControlId);
			$this->lblValue->Name = QApplication::Translate('Value');
			$this->lblValue->Text = $this->objMantisConfigTable->Value;
			$this->lblValue->Required = true;
			return $this->lblValue;
		}



		/**
		 * Refresh this MetaControl with Data from the local MantisConfigTable object.
		 * @param boolean $blnReload reload MantisConfigTable from the database
		 * @return void
		 */
		public function Refresh($blnReload = false) {
			if ($blnReload)
				$this->objMantisConfigTable->Reload();

			if ($this->txtConfigId) $this->txtConfigId->Text = $this->objMantisConfigTable->ConfigId;
			if ($this->lblConfigId) $this->lblConfigId->Text = $this->objMantisConfigTable->ConfigId;

			if ($this->txtProjectId) $this->txtProjectId->Text = $this->objMantisConfigTable->ProjectId;
			if ($this->lblProjectId) $this->lblProjectId->Text = $this->objMantisConfigTable->ProjectId;

			if ($this->txtUserId) $this->txtUserId->Text = $this->objMantisConfigTable->UserId;
			if ($this->lblUserId) $this->lblUserId->Text = $this->objMantisConfigTable->UserId;

			if ($this->txtAccessReqd) $this->txtAccessReqd->Text = $this->objMantisConfigTable->AccessReqd;
			if ($this->lblAccessReqd) $this->lblAccessReqd->Text = $this->objMantisConfigTable->AccessReqd;

			if ($this->txtType) $this->txtType->Text = $this->objMantisConfigTable->Type;
			if ($this->lblType) $this->lblType->Text = $this->objMantisConfigTable->Type;

			if ($this->txtValue) $this->txtValue->Text = $this->objMantisConfigTable->Value;
			if ($this->lblValue) $this->lblValue->Text = $this->objMantisConfigTable->Value;

		}



		///////////////////////////////////////////////
		// PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
		///////////////////////////////////////////////





		///////////////////////////////////////////////
		// PUBLIC MANTISCONFIGTABLE OBJECT MANIPULATORS
		///////////////////////////////////////////////

		/**
		 * This will save this object's MantisConfigTable instance,
		 * updating only the fields which have had a control created for it.
		 */
		public function SaveMantisConfigTable() {
			try {
				// Update any fields for controls that have been created
				if ($this->txtConfigId) $this->objMantisConfigTable->ConfigId = $this->txtConfigId->Text;
				if ($this->txtProjectId) $this->objMantisConfigTable->ProjectId = $this->txtProjectId->Text;
				if ($this->txtUserId) $this->objMantisConfigTable->UserId = $this->txtUserId->Text;
				if ($this->txtAccessReqd) $this->objMantisConfigTable->AccessReqd = $this->txtAccessReqd->Text;
				if ($this->txtType) $this->objMantisConfigTable->Type = $this->txtType->Text;
				if ($this->txtValue) $this->objMantisConfigTable->Value = $this->txtValue->Text;

				// Update any UniqueReverseReferences (if any) for controls that have been created for it

				// Save the MantisConfigTable object
				$this->objMantisConfigTable->Save();

				// Finally, update any ManyToManyReferences (if any)
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * This will DELETE this object's MantisConfigTable instance from the database.
		 * It will also unassociate itself from any ManyToManyReferences.
		 */
		public function DeleteMantisConfigTable() {
			$this->objMantisConfigTable->Delete();
		}



		///////////////////////////////////////////////
		// PUBLIC GETTERS and SETTERS
		///////////////////////////////////////////////

		/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				// General MetaControlVariables
				case 'MantisConfigTable': return $this->objMantisConfigTable;
				case 'TitleVerb': return $this->strTitleVerb;
				case 'EditMode': return $this->blnEditMode;

				// Controls that point to MantisConfigTable fields -- will be created dynamically if not yet created
				case 'ConfigIdControl':
					if (!$this->txtConfigId) return $this->txtConfigId_Create();
					return $this->txtConfigId;
				case 'ConfigIdLabel':
					if (!$this->lblConfigId) return $this->lblConfigId_Create();
					return $this->lblConfigId;
				case 'ProjectIdControl':
					if (!$this->txtProjectId) return $this->txtProjectId_Create();
					return $this->txtProjectId;
				case 'ProjectIdLabel':
					if (!$this->lblProjectId) return $this->lblProjectId_Create();
					return $this->lblProjectId;
				case 'UserIdControl':
					if (!$this->txtUserId) return $this->txtUserId_Create();
					return $this->txtUserId;
				case 'UserIdLabel':
					if (!$this->lblUserId) return $this->lblUserId_Create();
					return $this->lblUserId;
				case 'AccessReqdControl':
					if (!$this->txtAccessReqd) return $this->txtAccessReqd_Create();
					return $this->txtAccessReqd;
				case 'AccessReqdLabel':
					if (!$this->lblAccessReqd) return $this->lblAccessReqd_Create();
					return $this->lblAccessReqd;
				case 'TypeControl':
					if (!$this->txtType) return $this->txtType_Create();
					return $this->txtType;
				case 'TypeLabel':
					if (!$this->lblType) return $this->lblType_Create();
					return $this->lblType;
				case 'ValueControl':
					if (!$this->txtValue) return $this->txtValue_Create();
					return $this->txtValue;
				case 'ValueLabel':
					if (!$this->lblValue) return $this->lblValue_Create();
					return $this->lblValue;
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			try {
				switch ($strName) {
					// Controls that point to MantisConfigTable fields
					case 'ConfigIdControl':
						return ($this->txtConfigId = QType::Cast($mixValue, 'QControl'));
					case 'ProjectIdControl':
						return ($this->txtProjectId = QType::Cast($mixValue, 'QControl'));
					case 'UserIdControl':
						return ($this->txtUserId = QType::Cast($mixValue, 'QControl'));
					case 'AccessReqdControl':
						return ($this->txtAccessReqd = QType::Cast($mixValue, 'QControl'));
					case 'TypeControl':
						return ($this->txtType = QType::Cast($mixValue, 'QControl'));
					case 'ValueControl':
						return ($this->txtValue = QType::Cast($mixValue, 'QControl'));
					default:
						return parent::__set($strName, $mixValue);
				}
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}
	}
?>